#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int Abs(int A, int B)
{
	if (A > B)
	{
		return A - B;
	}
	return B - A;
}
void fun(int A, int n, int* b)
{
	int i = 0;
	int j = 0;
	int s = 0;
	int e = 0;
	int B = 0;
	int min = A;
	for (i = 0; i < n; i++)
	{
		B = b[i];
		for (j = i + 1; j <= n; j++)
		{
			if (Abs(A, B) < min)
			{
				min = Abs(A, B);
				s = i;
				e = j;
			}
			B += b[j];
		}
	}
	for (i = s; i < e; i++)
	{
		printf("%d ", b[i]);
	}
	printf("\n");
}
int main()
{
	int m = 0;
	int n = 0;
	scanf("%d %d", &m, &n);
	int a[10] = { 0 };
	int b[10] = { 0 };
	int A = 0;
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &a[i]);
		A += *(a + i);
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &b[i]);
	}
	fun(A, n, b);
	return 0;
}